package com.example.fb.adapter;

import java.math.BigInteger;

import com.example.fb.R;
import com.example.fb.activity.MainActivity;
import com.example.fb.sys.MySys;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class FbDataAdapter extends BaseAdapter {
	private LayoutInflater mInflater;

	public FbDataAdapter(Context context) {
		this.mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return MainActivity.mFbList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return MainActivity.mFbList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.sy_fb_content, null);
			holder.FbContent = (TextView) convertView
					.findViewById(R.id.fb_text);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		if (!MySys.isTurn) {
			holder.FbContent.setText(MainActivity.mFbList.get(position)
					.toString());
		} else {
			holder.FbContent.setText(MainActivity.mFbList.get(MainActivity.mFbList.size()-position-1)
					.toString());
		}
		return convertView;
	}

	private final class ViewHolder {
		public TextView FbContent;
	}

}
